let obj={
    'A.A':3,
    'A.B':5,
    'A.C.A':6,
    'B.A.A':2,
    'B.B':12,
    'C':8
}

function Func(obj){
    const result={};
    for(const key in obj){
        const value = obj[key];
        const keys = key.split('.');
        let current =result;
        
        for(let i=0;i<keys.length;i++){
            const k =keys[i]
            if(i===keys.length-1){
                current[k]=value;
            }
            else{
                if(!current[k]){
                    current[k]={};
                }

                current = current[k]
            }
        }
    }
    return result
}

console.log(Func(obj))